<html>
    <head>
        <meta name="layout" content="thin_sidebar" />
        <g:set var="entityName" value="Item" />
        <content tag="title">${pageTitle}</content>
    </head>
    <body>
<% if (itemInstance) { %>
        <div class="crumb">
            <ts:itemLink item="${itemInstance}">${itemInstance.title}</ts:itemLink> &gt;
            Downloads list
        </div>
        <div class="clear"></div>
        <div class="rule"><hr /></div>
        <div class="body hentry">
    <% if (downloadsList?.totalCount > 0) { %>
            <table class="download-list" cellspacing="0">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Size</th>
                        <th>Seeds</th>
                        <th>Peers</th>
                        <th>Completed</th>
                    </tr>
                </thead>
                <tbody>
        <g:each in="${downloadsList}" status="i" var="download">
                    <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                        <td>
                            <ts:downloadLink torrent="${download}"><img src="/images/icons/download_16x16.png" title="Download torrent" alt="Download torrent" /></ts:downloadLink>
                            <ts:torrentLink torrent="${download}">${download.name.encodeAsHTML()}</ts:torrentLink>
            <g:if test="${canEditItem}">
                                <g:link controller="torrent" action="delete" id="${download.infoHash}" title="Delete download"
                                    onclick="return confirm('${message(code: 'torrent.delete.confirm.message')}');" ><img src="${fam.icon(name: 'delete')}" alt="delete"/></g:link>
            </g:if>
                        </td>
                        <td><ts:formatFileSize file_size="${download.size}" precision="2"/></td>
                        <td><ts:torrentSeedCount torrent="${download}" /></td>
                        <td>${download?.stats ? download?.stats?.peers : 0}</td>
                        <td>${download?.stats ? download?.stats?.completed : 0}</td>
                    </tr>
        </g:each>
                </tbody>
            </table>

            <div class="pagination">
                <g:paginate id="${params.id}" total="${downloadsList.totalCount}" prev="&laquo; Previous" next="Next &raquo;"/>
            </div>
    <% } else { %>
                This item has no downloads.
    <% } // if downloadsList.totalCount > 0 %>
        </div><!-- .body -->
<% } // if itemInstance %>
    </body>
</html>
